package th;

/**
 * @author Mark
 * @version 1.0
 * @date 2020/5/24 10:18
 * @description 线程礼让(看cpu心情)
 */
public class ThreadYield {

    public static void main(String[] args) {
        MyYield myYield = new MyYield();
        new Thread(myYield, "a = ").start();
        new Thread(myYield, "b = ").start();

    }
}

class MyYield implements Runnable {

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + "thread is started");
        Thread.yield();
        System.out.println(Thread.currentThread().getName() + "thread is stop");
    }
}